<?php
  require_once 'lib/HTML/Util.php';
  require_once 'lib/HTML/LinkLoader.php';
  require_once 'controllers/User.php';
 
  if(is_numeric($_GET['uid']) && $_GET['uid'] > 0)
  {
  	    
  $user = new User(array(id=>$_GET['uid']));
  try{ $user->getDetails(); }
  catch(MTException $e){ die($e->getMessage()); }

  if($user->result() == null)
      header("Location: ?view=artist&action=listen&aid={$_GET['aid']}&error=not+found");
   
  $smarty->assign_by_ref("user_info",$user->result());
  $smarty->assign('time_added', $user->getTime());
  $smarty->assign("title", "User: {$user->result()->name}");
  
  try
  { 
  	$pl = $user->getPlayList()->result();
    $smarty->assign_by_ref("user_playlist", $pl);
    $smarty->assign("tracks_no", sizeof($pl));
  }
  catch(MTException $e){ die($e->getMessage()); }
  
  }else{
      header("Location: index.php");
  }
    
  $ll = new LinkLoader();
  $ll->loadCSS(array('listen.css'));
  
  $ll->loadJs(array('Ajax.js','WebServices/WebService.js',
                    'WebServices/MusicBrainz.js','Components/Track.js',
                    'Components/Article.js','MusicTalk.js','Tabs.js','WebServices/YouTubeVids.js','lib/swfobject.js','Player.js'));
  $ll->loadJs('js.js','views/user/listen/');
  
  $smarty->assign_by_ref("ll", $ll);
  $smarty->assign_by_ref("html",new Util());
  //$smarty->assign_by_ref("fe",new FormElements());
     
  $smarty->display("head.tpl");
  $smarty->display("nav.tpl");
  // main content
  $smarty->display("../user/listen/view.tpl");
  
  $smarty->display("footer.tpl");
?>

    
    
